// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

Item {
    id: m_text_input
    width: 480
    height: 854
    state: "hide"

    property string title_text: ""

    signal confirm(string inputtext)
    signal cancel()

    Component.onCompleted:
    {
        m_text_input.state = "";
    }

    Rectangle {
        id: bg
        color: "#000000"
        opacity: 0.700
        anchors.fill: parent

        MouseArea
        {
            anchors.fill: parent
            onClicked: {}
        }
    }

    Rectangle {
        id: rectangle1
        x: 0
        y: 0
        width: 480
        height: 300
        color: "#000000"

        Text {
            id: title
            color: "#ffffff"
            text: title_text
            anchors.left: parent.left
            anchors.leftMargin: 40
            anchors.top: parent.top
            anchors.topMargin: 25
            font.pixelSize: 44
        }

        Rectangle {
            id: rectangle_input
            x: 24
            width: 400
            height: 50
            color: "#ffffff"
            anchors.top: title.bottom
            anchors.topMargin: 25
            anchors.horizontalCenter: parent.horizontalCenter

            TextInput {
                id: input
//                x: 16
                y: 5
                width: 370
                height: 50
                text: ""
                anchors.horizontalCenter: parent.horizontalCenter
//                anchors.verticalCenter: parent.verticalCenter
                font.pixelSize: 33
            }
        }

        Mbutton {
            id: mbutton_confirm
            y: 206
            pro_height: 60
            textstring: "确认"
            text_size: 33
            pro_width: 160
            anchors.left: parent.left
            anchors.leftMargin: 40
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 15

            onButtonclick:
            {
                confirm(input.text);
            }
        }

        Mbutton {
            id: mbutton_cancel
            x: 254
            y: 206
            textstring: "取消"
            pro_height: 60
            text_size: 33
            pro_width: 160
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 15
            anchors.right: parent.right
            anchors.rightMargin: 40

            onButtonclick:
            {
                cancel();
            }
        }
    }

    states: [
        State {
            name: "hide"

            PropertyChanges {
                target: rectangle1
                y: -300
            }
        }
    ]

    transitions: Transition {
        // Make the state changes smooth
        ParallelAnimation {
            NumberAnimation { duration: 100; properties: "y"; easing.type: Easing.OutQuad }
        }
    }
}
